import { api } from './Request'
import _ from './../utils/util'

const API = (method: string, ...args: [string, any]): Promise<Response> => _.to(api(method, ...args))

export const GET = (...args: [string, any]): Promise<Response> => API('get', ...args)
export const POST = (...args: [string, any]): Promise<Response> => API('post', ...args)
export const PUT = (...args: [string, any]): Promise<Response> => API('put', ...args)
export const DELETE = (...args: [string, any]): Promise<Response> => API('delete', ...args)
export const PATCH = (...args: [string, any]): Promise<Response> => API('patch', ...args)

export default {
    GET,
    POST,
    PUT,
    DELETE,
    PATCH,
}